package com.atguigu.day09;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

public class Flink10_SQL_ProcTime {
    public static void main(String[] args) {
        //1.获取相关环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

        //TODO 2.在DDL建表语句中指定处理时间
        tableEnv.executeSql("create table sensor(" +
                        "id String," +
                        "ts bigint," +
                        "vc int," +
                        "pt as proctime()" +
                        ") with(" +
                        "'connector' = 'filesystem'," +
                        "'path' = 'input/sensor.txt'," +
                        "'format' = 'csv'"+
                ")");

        tableEnv.executeSql("select * from sensor").print();
    }
}
